package com.kxf.utils;

import android.content.Intent;
import android.os.Bundle;

import java.util.Set;

/**
 * @ProjectName: AndroidTestDemo
 * @Package: com.kxf.androidtestdemo.utils
 * @ClassName: Util
 * @Description: java类作用描述
 * @Author: kuangxuefeng
 * @qq: 1024883177
 * @CreateDate: 2021/5/20 9:27
 */
public class Util {
    public static String getIntentExtrasToString(Intent data) {
        if (null == data) {
            return null;
        }
        return getBundleToString(data.getExtras());
    }

    public static String getBundleToString(Bundle data) {
        if (null == data) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        Set<String> keys = data.keySet();
        if (null != keys && keys.size() > 0) {
            for (String key : keys) {
                sb.append(" [" + key + "=" + data.get(key) + "]");
            }
        }
        return sb.toString();
    }
}
